package com.taiyuan.tongcheng.ui;

import im.yixin.sdk.util.StringUtil;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;
import org.kymjs.kjframe.KJActivity;
import org.kymjs.kjframe.KJHttp;
import org.kymjs.kjframe.http.HttpCallBack;
import org.kymjs.kjframe.http.HttpConfig;
import org.kymjs.kjframe.http.HttpParams;
import org.kymjs.kjframe.ui.BindView;
import org.kymjs.kjframe.ui.ViewInject;
import org.kymjs.kjframe.utils.KJLoger;
import org.kymjs.kjframe.utils.StringUtils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.facebook.rebound.SteppingLooper;
import com.taiyuan.tongcheng.adapter.CarKindAdapter;
import com.taiyuan.tongcheng.adapter.PayKindAdapter;
import com.taiyuan.tongcheng.application.TCBroadcastAction;
import com.taiyuan.tongcheng.bean.MovingOrderSimple;
import com.taiyuan.tongcheng.bean.SelectDate;
import com.taiyuan.tongcheng.bean.ServerStation;
import com.taiyuan.tongcheng.bean.SystemConfig;
import com.taiyuan.tongcheng.config.TcConfig;
import com.taiyuan.tongcheng.db.TcDbHelper;
import com.taiyuan.tongcheng.http.HttpParamUtil;
import com.taiyuan.tongcheng.http.TcWebservice;
import com.taiyuan.tongcheng.http.WebData;
import com.taiyuan.tongcheng.jsonparser.TcJsParser;
import com.taiyuan.tongcheng.map.MapAddSActivity;
import com.taiyuan.tongcheng.util.ACache;
import com.taiyuan.tongcheng.util.TimeUtil;
import com.taiyuan.tongcheng.view.multichecklistview.MovingService;
import com.taiyuan.tongcheng.view.multichecklistview.MovingServiceAdapter;
import com.taiyuan.tongcheng.view.pickerview.OptionsPopupWindow;
import com.taiyuan.tongcheng.view.pickerview.OptionsPopupWindow.OnIMClickListener;
import com.taiyuan.tongcheng.view.pickerview.OptionsPopupWindow.OnOptionsSelectListener;
import com.taiyuan.tongcheng.widget.collswtich.CheckSwitchButton;
import com.tytc56.user.R;

/**
 * 
* @Description 预约搬家界面
* @author wzq
* @date 2015-7-24 下午4:58:38
* @update (date)
* @version V1.0
 */
public class MovingActivity extends BaseActivity  implements OnCheckedChangeListener{
	//1 widget
	@BindView(id = R.id.tv_common_instruction,click=true)
	private TextView instruction;
	@BindView(id=R.id.rl_moving_time,click=true)
	private RelativeLayout  timeRl;
	@BindView(id=R.id.rl_moving_start,click=true)
	private RelativeLayout  startRl;
	@BindView(id=R.id.rl_moving_destination,click=true)
	private RelativeLayout  endRl;
	@BindView(id=R.id.tv_movingTime)
	private TextView  movingTime;
	@BindView(id=R.id.tv_movingStart)
	private TextView  movingStart; //起始点
	@BindView(id=R.id.tv_moving_destination)
	private TextView  movingEnd; //终点
	@BindView(id=R.id.rl_moving_service,click=true)
	private RelativeLayout serviceRl;
	@BindView(id=R.id.img_service_arrow,click=true)
	private ImageView serviceArrowImg;
	
	//联系方式
	@BindView(id=R.id.tv_moving_phone)
	private TextView  telNoTv;
	@BindView(id=R.id.tv_moving_name)
	private TextView  nameTv;
	@BindView(id=R.id.rl_moving_connect_phone,click=true)
	private RelativeLayout  telRelative;
	
	//楼梯选择
	@BindView(id=R.id.cb_start)
	private CheckSwitchButton startSwitchBtn;
	@BindView(id=R.id.ll_moving_floor_start)
	private LinearLayout movingFloorLLS;
	@BindView(id=R.id.cb_destination)
	private CheckSwitchButton endSwitchBtn;
	@BindView(id=R.id.ll_moving_floor_end)
	private LinearLayout movingFloorLLE;
	@BindView(id=R.id.et_startfloor)
	private EditText startFloor;
	@BindView(id=R.id.et_destination_floor)
	private EditText endFloor;
	// 车型选择
	@BindView(id = R.id.lv_car_select)
	private ListView carStyleListView;
	@BindView(id = R.id.rl_car_style, click = true)
	private RelativeLayout carStyleRl;
	@BindView(id = R.id.img_carstyle_arrow)
	private ImageView carStyleArrowImg;
	@BindView(id = R.id.tv_car_item)
	private TextView catSelect;
	private PayKindAdapter carPayAdapter;
	// 支付选择
		@BindView(id = R.id.lv_pay_select)
		private ListView payStyleListView;
		@BindView(id = R.id.rl_pay_style, click = true)
		private RelativeLayout payStyleRl;
		@BindView(id = R.id.img_pay_arrow)
		private ImageView payStyleArrowImg;
		@BindView(id = R.id.tv_pay_item)
		private TextView paySelect;
	//选择优惠卷
	@BindView(id=R.id.rl_coupon,click=true)
	private RelativeLayout  couponRl;
	@BindView(id=R.id.tv_coupon)
	private TextView couponRsTv;
	
	// 司机留言
	@BindView(id = R.id.rl_drvicer_msg, click = true)
	private RelativeLayout driver_msg;
	@BindView(id = R.id.tv_order_remarks)
	private TextView msgTv;
//	bottom
	@BindView(id=R.id.btn_next,click=true)
	private Button nextBtn;
	
	//时间选择控件、 滚动选择框
	private ArrayList<String> options1Items = new ArrayList<String>();
	private ArrayList<ArrayList<String>> options2Items = new ArrayList<ArrayList<String>>();
	private ArrayList<ArrayList<ArrayList<String>>> options3Items = new ArrayList<ArrayList<ArrayList<String>>>();
	OptionsPopupWindow pwOptions;
	List<SelectDate> selectDateList; 
	
	//3UI和适配
	private MovingServiceAdapter  serviceAdapter;
	private boolean clickState=false;
	private List<MovingService> serviceList=new ArrayList<MovingService>();
	private CarKindAdapter carStyleAdapter;
	
	//下单数据
	private MovingOrderSimple  movingOrder;
	private ServerStation  station;
	
	//缓存
	private ACache  acache;
	
    //result 
	public static final int RES_CODE_START_POINT =0x01;	
	public static final int RES_CODE_DESTNITION_POINT =0x02;	
	public static final int RES_CODE_DRIVER_MSG =0x04;	//
	public static final int RES_CODE_COUPON =0x05;	
	public static final int RES_CODE_TEL =0x06;	
	private Intent inputStaIntent;//输入页intent
	private Intent couponIntent;//优惠卷
	private Intent telIntent;//联系人信息
	public static String TAG_MOVING_ORDER="moving_order";//缓存搬家数据的缓存
	public static String TAG_MOVING_ORDER_PRICE="moving_price";//搬家业务价钱
	public static String TAG_MOVING_CONNECT_NAME="moving_name";//联系人
	public static String TAG_MOVING_CONNECT_TEL="moving_tel";//联系电话
	//广播
	private IntentFilter  intentFilter;
	@Override
	public void setRootView() {
		setContentView(R.layout.activity_moving_ui1);
	}
	
	@Override
	public void initData() {
		super.initData();
		movingOrder=new MovingOrderSimple();
		getSystemConfig();
	}
	/**
	 * 
	* @Description: 注册广播
	* @return void
	* @throws
	* @autour Administrator
	* @date 2015年9月19日 下午11:08:04 
	* @update (date)
	 */
    private void initReceiver() {
    	intentFilter=new IntentFilter();
    	intentFilter.addAction(TCBroadcastAction.SUCCESS_MAKE_ORDER);
    	registerReceiver(receiver, intentFilter);
	}
    
    private BroadcastReceiver  receiver =new BroadcastReceiver() {
		
		@Override
		public void onReceive(Context context, Intent intent) {
			MovingActivity.this.finish();
		}
	};

	@Override
	public void initWidget() {
		super.initWidget();
		initView();
		
		acache=ACache.get(getApplicationContext());
		station=(ServerStation)getIntent().getSerializableExtra(MainActivitySlide.LABLE_START_STA);
		movingOrder.setStartPlace(station.getPlace());
		movingOrder.setStartLatitude(station.getLatitude());
		movingOrder.setStartLongitude(station.getLongitude());
		movingOrder.setStartCity(spUtil.getLocationCity());
		movingOrder.setStartProvince(spUtil.getLocationProvice());
		movingOrder.setStartCityCode(spUtil.getLocationCityCode());
		if(StringUtils.isEmpty(station.getPlace())){
			movingStart.setText(R.string.moving_start);
		}else{
			movingStart.setText(movingOrder.getStartPlace());
		}
		movingOrder.setReceiver(TcDbHelper.getUser(getApplicationContext()).getName());
		movingOrder.setReceiverMobile(TcDbHelper.getUser(getApplicationContext()).getMobile());
		
		//receiver广播
		initReceiver(); 
		//初始化Intent
		inputStaIntent=new Intent(this,AddressSelectActivity.class);
		couponIntent=new Intent(this,CardListActivity.class);
		telIntent=new Intent(this,InputTelActivitity.class);
		//1 绑定开关事件
		startSwitchBtn.setChecked(true);
		endSwitchBtn.setChecked(true);
		movingFloorLLS.setVisibility(View.GONE);
		movingFloorLLE.setVisibility(View.GONE);
		startSwitchBtn.setOnCheckedChangeListener(this);
		endSwitchBtn.setOnCheckedChangeListener(this);
		//初始化显示
		telNoTv.setText(TcDbHelper.getUser(getApplicationContext()).getMobile());
		topTv.setText(getString(R.string.main_moving_title));
		carStyleAdapter = new CarKindAdapter(this);
		carStyleListView.setAdapter(carStyleAdapter);
		carStyleAdapter.setSlectPositon(2);
		catSelect.setText(carStyleAdapter.carName[2]);
		carStyleListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				carStyleAdapter.setSlectPositon(arg2);
				carStyleAdapter.notifyDataSetChanged();
				catSelect.setText(carStyleAdapter.carName[arg2]);
				carStyleListView.setVisibility(View.GONE);
			}
		});
		// 初始化支付方式
				carPayAdapter = new PayKindAdapter(this);
				payStyleListView.setAdapter(carPayAdapter);
				payStyleListView.setOnItemClickListener(new OnItemClickListener() {
					@Override
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {
						carPayAdapter.setSlectPositon(position);
						paySelect.setText(PayKindAdapter.payName[position]);
						payStyleListView.setVisibility(View.GONE);
					}
				});
				paySelect.setText(getString(R.string.select));
		//2 时间选择
		initTimeWidget();
	}
	
	
	private void initTimeWidget() {
		final Calendar now = Calendar.getInstance();
		// 时间选择器
		pwOptions = new OptionsPopupWindow(this,false);
		
		selectDateList = TimeUtil.getList(TcConfig.LIMIT_HOUR);
		for (int i = 0; i < selectDateList.size(); i++) {
			options1Items.add(selectDateList.get(i).getDateLable());
		}

		// 选项2
		for (int i = 0; i < selectDateList.size(); i++) {
			ArrayList<String> options2ItemsTem = new ArrayList<String>();

			if (i == 0) {
				for (int j = (now.get(Calendar.HOUR_OF_DAY)+3)%24; j < TcConfig.HOUR.length; j++) {
					options2ItemsTem.add(TcConfig.HOUR[j]);
				}
			} else {
				for (int j = 0; j < TcConfig.HOUR.length; j++) {
					options2ItemsTem.add(TcConfig.HOUR[j]);
				}
			}
			options2Items.add(options2ItemsTem);
		}

		// 选项3
		for (int i = 0; i < selectDateList.size(); i++) {
			ArrayList<ArrayList<String>> options3ItemsBitemp = new ArrayList<ArrayList<String>>();

			for (int j = 0; j < TcConfig.HOUR.length; j++) {
				ArrayList<String> options3ItemsTem = new ArrayList<String>();
				options3ItemsTem.add("0");
				options3ItemsTem.add("30");
				options3ItemsBitemp.add(options3ItemsTem);
			}
			options3Items.add(options3ItemsBitemp);
		}

		// 三级联动效果
		pwOptions.setPicker(options1Items, options2Items, options3Items, true);
		// 设置默认选中的三级项目
		pwOptions.setSelectOptions(0, 0, 0);
		// 监听确定选择按钮
		pwOptions.setOnoptionsSelectListener(new OnOptionsSelectListener() {

			@Override
			public void onOptionsSelect(int options1, int option2, int options3) {
				// 返回的分别是三个级别的选中位置
				KJLoger.debug(options1 + "ss" + option2 + "ss" + options3);
				StringBuilder builder = new StringBuilder();
				KJLoger.debug(builder.toString());
				String tx = options1Items.get(options1)
						+ options2Items.get(options1).get(option2)
						+ options3Items.get(options1).get(option2)
								.get(options3);
				KJLoger.debug(selectDateList.get(options1).getDateValue()+TcConfig.HOUR_VALUE[option2]+TcConfig.MINUTE_VALUE[options3]);
				movingTime.setText(tx);
				if(options1==0){
					movingOrder.setServiceDate(selectDateList.get(options1).getDateValue()+TcConfig.HOUR_VALUE[((now.get(Calendar.HOUR_OF_DAY)+3+option2)%24)]+TcConfig.MINUTE_VALUE[options3]);
					KJLoger.debug(TcConfig.HOUR_VALUE[((now.get(Calendar.HOUR_OF_DAY)+3+option2)%24)]);
				}else{
					movingOrder.setServiceDate(selectDateList.get(options1).getDateValue()+TcConfig.HOUR_VALUE[option2]+TcConfig.MINUTE_VALUE[options3]);
					
				}
				KJLoger.debug(movingOrder.getServiceDate());
			}
		});

		pwOptions.setOnIMClickLIstener(new OnIMClickListener() {

			@Override
			public void onImclick(int falg) {
				if (falg == 1) {
					movingTime.setText("现在");
				}
			}
		});
	}
	
	
	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);
		switch (v.getId()) {
		case R.id.tv_common_instruction:
			Bundle  bundle =new Bundle();
			bundle.putInt(TcWebviewActivity.TAG_COMFROM, TcWebviewActivity.TAG_MOVING_INFORM);
			bundle.putString(TcWebviewActivity.TAG_TOP_TITLE, "使用说明");
			startActivity(TcWebviewActivity.class, bundle);
			break;
		case R.id.rl_moving_start:
			inputStaIntent.putExtra(AddressSelectActivity.TAG_MAP_INPUT, "请输入起始地");
			startActivityForResult(inputStaIntent,RES_CODE_START_POINT);	
			break;
		case R.id.rl_moving_destination:
			inputStaIntent.putExtra(AddressSelectActivity.TAG_MAP_INPUT, "请输入目的地");
			startActivityForResult(inputStaIntent,RES_CODE_DESTNITION_POINT);	
			break;
		case R.id.rl_moving_time:
			pwOptions.showAtLocation(timeRl, Gravity.BOTTOM, 0, 0);
			break;
			
		case R.id.btn_top_back:
			MovingActivity.this.finish();
			break;
			
		case R.id.btn_next:
			movingOrder.setReceiverMobile(TcDbHelper.getUser(getApplicationContext()).getMobile());
			movingOrder.setPayTypeId(carPayAdapter.getSelecPosition());
			if(checkMovingParNull()){
				if(startSwitchBtn.isChecked()){
					movingOrder.setStartFloor("");
					movingOrder.setStartIsLift("1");
				}else{
					movingOrder.setStartFloor(startFloor.getText().toString());
					movingOrder.setStartIsLift("0");
				}
				if(endSwitchBtn.isChecked()){
					movingOrder.setEndFloor("");
					movingOrder.setEndIsLift("1");
				}else{
					movingOrder.setEndFloor(endFloor.getText().toString());
					movingOrder.setEndIsLift("0");
				}
				movingOrder.setPayTypeId(carPayAdapter.getSelecPosition());
				movingOrder.setTruckTypeId(carStyleAdapter.getSelecPosition());
				//待加入
				acache.put(TAG_MOVING_ORDER, movingOrder);
				startActivity(new Intent(MovingActivity.this,MovingListActivity.class));
			}
			
			break;	
		case R.id.rl_car_style:
			if (carStyleListView.getVisibility() == View.GONE) {
				carStyleListView.setVisibility(View.VISIBLE);
				carStyleArrowImg
						.setImageResource(R.drawable.icon_arrow_down_default);
			} else {
				carStyleListView.setVisibility(View.GONE);
				carStyleArrowImg
						.setImageResource(R.drawable.icon_arrow_right_default);
			}
			break;
			
		case R.id.rl_coupon:
			couponIntent.putExtra(CardListActivity.TAG_MONEY_CARD_FROM, 1);
       		startActivityForResult(couponIntent, RES_CODE_COUPON);
			break;
		case R.id.rl_moving_connect_phone:
			telIntent.putExtra(MovingActivity.TAG_MOVING_CONNECT_NAME,movingOrder.getReceiver() );
			telIntent.putExtra(MovingActivity.TAG_MOVING_CONNECT_TEL, movingOrder.getReceiverMobile());
			startActivityForResult(telIntent, RES_CODE_TEL);
			break;
			
		case R.id.rl_drvicer_msg:
			startActivityForResult(new Intent(this, DriverMsgActivity.class), RES_CODE_DRIVER_MSG);
			break;
		case R.id.rl_pay_style:
			if (payStyleListView.getVisibility() == View.GONE) {
				payStyleListView.setVisibility(View.VISIBLE);
				payStyleArrowImg
						.setImageResource(R.drawable.icon_arrow_down_default);
			} else {
				payStyleListView.setVisibility(View.GONE);
				payStyleArrowImg
						.setImageResource(R.drawable.icon_arrow_right_default);
			}
			break;
		default:
			break;
		}
		
	}

	@Override
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		switch (buttonView.getId()) {
		case R.id.cb_start :
			  if(isChecked){ 
				  movingFloorLLS.setVisibility(View.GONE);
              }else{ 
            	  movingFloorLLS.setVisibility(View.VISIBLE);
              } 
			break;
		case R.id.cb_destination :
			  if(isChecked){ 
				  movingFloorLLE.setVisibility(View.GONE);
              }else{ 
            	  movingFloorLLE.setVisibility(View.VISIBLE);
              } 
			break;

		default:
			break;
		}
		
	}

	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		switch (requestCode) {
		case RES_CODE_DRIVER_MSG:
			if (resultCode == RESULT_OK) {
				String result = data.getStringExtra("MESSAGE");
				msgTv.setText(result);
				movingOrder.setNote(result);
			}
			break;
		case RES_CODE_TEL:
			if (resultCode == RESULT_OK) {
				String name = data.getStringExtra(TAG_MOVING_CONNECT_NAME);
				String tel =  data.getStringExtra(TAG_MOVING_CONNECT_TEL);
				KJLoger.debug(name+tel);
				telNoTv.setText(tel);
				nameTv.setText(name);
				movingOrder.setReceiver(name);
				movingOrder.setReceiverMobile(tel);
			}
			break;
		case RES_CODE_COUPON:
			if (resultCode == RESULT_OK) {
				String result = data.getStringExtra(CardListActivity.TAG_CARD_NO);
				String price =data.getStringExtra(CardListActivity.TAG_CARD_PRICE);
				if(!StringUtils.isEmpty(result)){
					if(result.equals("no")){
						movingOrder.setCouponId("");;
						couponRsTv.setText(R.string.coupon_no_use);
					}else{
						movingOrder.setCouponId("result");
						movingOrder.setCouponPrice(Double.parseDouble(price));
						couponRsTv.setText("使用面额为"+price+"的优惠券");
					}
				}
			}
			break;
			
		case RES_CODE_START_POINT:
			
			if (resultCode == RESULT_OK) {
				ServerStation  station= (ServerStation)data.getSerializableExtra(AddressSelectActivity.TAG_MAP_POINT);
				if(station!=null){
					movingOrder.setStartProvince(station.getProvince());
					movingOrder.setStartCity(station.getCity());
					movingOrder.setStartCityCode(station.getCityCode());
					movingOrder.setStartPlace(station.getPlace());
					movingOrder.setStartLatitude(station.getLatitude());
					movingOrder.setStartLongitude(station.getLongitude());
					movingStart.setText(station.getPlace());
//					movingOrder.setStartFloor(startFloor);
//					movingOrder.setStartIsLift(startIsLift);
				}
			}
			
			break;
		case RES_CODE_DESTNITION_POINT:
			if (resultCode == RESULT_OK) {
				ServerStation  station= (ServerStation)data.getSerializableExtra(AddressSelectActivity.TAG_MAP_POINT);
				if(station!=null){
				movingOrder.setEndProvince(station.getProvince());
				movingOrder.setEndCity(station.getCity());
				movingOrder.setEndCityCode(station.getCityCode());
				movingOrder.setEndPlace(station.getPlace());
				movingOrder.setEndLatitude(station.getLatitude());
				movingOrder.setEndLongitude(station.getLongitude());
				movingEnd.setText(station.getPlace());
				}
//				movingOrder.setEndFloor(startFloor);
//				movingOrder.setEndIsLift(startIsLift);
			}
			break;
		default:
			break;
		}
	}
	
	/**
	 * 
	* @Description: 检测输入参数
	* @return
	* @return boolean
	* @throws
	* @autour wzq
	* @date 2015-9-17 下午1:39:36
	* @update (date)
	 */
	public boolean checkMovingParNull(){
		if(StringUtils.isEmpty(movingOrder.getStartPlace())){
			showErroCustomToast("请输入搬家起始点");
			return false;
		}
		if(StringUtils.isEmpty(movingOrder.getEndPlace())){
			showErroCustomToast("请输入目的地");
			return false;
		}
		if(!startSwitchBtn.isChecked()){
			if(StringUtils.isEmpty(startFloor.getText())){
				showErroCustomToast("请输入楼层");
				return false;
			}
		}
		if(!endSwitchBtn.isChecked()){
			if(StringUtils.isEmpty(endFloor.getText())){
				showErroCustomToast("请输入楼层");
				return false;
			}
		}
		if (StringUtils.isEmpty(movingOrder.getServiceDate())) {
			showErroCustomToast("请输入搬家时间");
			return false;
		}
		
		
		if(StringUtils.isEmpty(movingOrder.getReceiver())){
			showErroCustomToast("请输入联系人");
			return false;
		}
		
		if(StringUtils.isEmpty(movingOrder.getReceiverMobile())){
			showErroCustomToast("请输入联系人电话");
			return false;
		}
		
		if(movingOrder.getPayTypeId()==0){
			showErroCustomToast(getString(R.string.error_null_pay));
			return false;
		}
		return true;
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		unregisterReceiver(receiver);
	}
	
	 /**
     * 获取系统配置信息
     */
    private void getSystemConfig() {
    	
    	HttpConfig config = new HttpConfig();
		config.cacheTime = 0;
    	KJHttp kjHttp = new KJHttp(config);
		HttpParams params = HttpParamUtil.getSystemConfig(getApplicationContext());
		kjHttp.post(TcWebservice.WEBSERVER_IP + TcWebservice.API.APP_GETCONFIG,
				params, new HttpCallBack() {
					@Override
					public void onFailure(int errorNo, String strMsg) {
						super.onFailure(errorNo, strMsg);
					}
					@Override
					public void onSuccess(String t) {
						super.onSuccess(t);
						try {
							String response = URLDecoder.decode(t, "UTF-8");
							KJLoger.debug(response);
							WebData data = new WebData();
							data = TcJsParser.getWedataData(response);
							if (data.getStatus() == 1) {
								 SystemConfig  config=JSON.parseObject(data.getData(), SystemConfig.class);
								   if(!StringUtils.isEmpty(config.getCallImZcNoResTimes())){
									   spUtil.setWaitTimes(Integer.parseInt(config.getCallImZcNoResTimes()));
								   }
								   if(!StringUtils.isEmpty(config.getImExpireTime())){
									   spUtil.setImExpireTime(1000*Integer.parseInt(config.getImExpireTime()));
								   }
								   if(!StringUtils.isEmpty(config.getBjDiscountValue())){
									   spUtil.setBjDiscount(config.getBjDiscountValue());
								   }
								   
							} else {
								
							}

						} catch (UnsupportedEncodingException e) {
							e.printStackTrace();
						}
					}
					@Override
					public void onFinish() {
						super.onFinish();
					}
				});

	}
	
	
}
